using UnityEngine;

namespace Voodoo.Distribution
{
	public sealed class LocalizationDebugger : MonoBehaviour
	{
		private const KeyCode _debugKeyForNextLanguage = KeyCode.L;

		private const KeyCode _debugKeyForLongestStringMode = KeyCode.O;

		public bool longestStringModeEnabled;

		private int _forcedIndex = -1;

		private string[] _languageCodes;

		private void Awake()
		{
			_languageCodes = Localization.LanguageCodes;
			Object.DontDestroyOnLoad(this);
		}

		private void Update()
		{
			if (Input.GetKeyDown(KeyCode.L))
			{
				longestStringModeEnabled = false;
				_forcedIndex = (_forcedIndex + 1) % _languageCodes.Length;
				Localization.forcedLanguage = _languageCodes[_forcedIndex];
				Localization.TranslateAll();
			}
			if (Input.GetKeyDown(KeyCode.O))
			{
				longestStringModeEnabled = true;
				Localization.TranslateAll();
			}
		}
	}
}
